<?php
  include("../db.php");

  $username = $_POST["username"];
  $password = $_POST["password"];
  $phone = $_POST["phone"];

  $sql = "insert into users (username,phone, password) values ('$username','$phone','$password')";
  $result = mysql_query($sql);

  $array = array("res_code"=>1, "res_error"=>"");

  if ($result) {
		$res_body = array("status"=>1);
		// 将保存成功的记录重新查询出来
		$sql = "SELECT * FROM users ORDER BY id DESC LIMIT 0, 1";
		// 执行查询
		$result = mysql_query($sql);
		// 将查询出的记录放置到 $row 数组中
		$row = mysql_fetch_assoc($result);
		$res_body["data"] = $row;
	} else {
		$res_body = array("status"=>0, "message"=>"有误：" . mysql_error());
	}
	// 构建返回的关联数组
	$array["res_body"] = $res_body;
	// 返回JSON文本
	echo json_encode($array);
	// 关闭
	mysql_close();

?>
